<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>猜数游戏</title>
</head>
<body>

    <script src="JQrery.js"></script>

    <button id="reset">重新开始</button><br/>
    请输入猜测的数字：<input type="text" id="userGets"><br/>
    <button id="guess">确认</button><br/>
    已经猜测的次数：<span id="count"></span><br/>
    结果：<span id="result"></span><br/>

    <script>
        var number = Math.floor(Math.random()*100)+1;
        var count = 0;
        $("#guess").click(function(){
            count++;
            $("#count").text(count);
            var userGets = $("#userGets").val();
            if(userGets > number){
                $("#result").text("猜大了");
                $("#result").css("color","red");
            }else if(userGets < number){
                $("#result").text("猜小了");
                $("#result").css("color","red");
            }else{
                $("#result").text("猜到了");
                $("#result").css("color","blue");
            }
        });
        $("#reset").click(function(){
            var number = Math.floor(Math.random()*100)+1;
            console.log("number: "+number);
            var count = 0;
            $("#count").text(" ");
            $("#result").text(" ");
        });
    </script>


    











</body>
</html>